package testy;

public class Ventilation 
{
    //variables
    private double ventilationFactor;    // (W/m3)
    private double area;                        //Hus areal (m2)
    private double wallsHeight;                 
    private double volume;
    private double temperatureDifference;       //forskjell i temperatur inn og ute (C)
    private double airChanges;
    private int roomType;
    
    
    private double ventilationHour;             //(W)
    //end of variables
    
    public Ventilation()
    {
    }
    
    /**
     * Centilation constructor
     * @param _area hus størrelse i m2
     * @param _wallsHeight
     * @param _temperatureDifference temperatur forskjell i C
     * @param _roomType 0 - små hus, 1
     */
    public Ventilation(double _area, double _wallsHeight,double _temperatureDifference, int _roomType)
    {
        area = _area;
        wallsHeight = _wallsHeight;
        temperatureDifference = _temperatureDifference;
        roomType = _roomType;
        ventilationFactor = 0.33;
        volume = area * wallsHeight;
    }//end of constructor
    
    /**
     * Klass innholder ikke alt, skal videreutvikles!!!
     */
    private void airExchangeDependingOnTheTypeOfRoom()
    {
        if (roomType == 0)
        {
            airChanges = 2;
        }
        else if(roomType == 1)
        {
            airChanges = 4;
        }
        else
        {
            airChanges = 4;
        }
    }
    
    /**
     * Beregner energitap på grunn av ventilasjon
     * @return energi (W)
     */
    public double CalculationTime()
    {
        airExchangeDependingOnTheTypeOfRoom();  //Set airChanges factor
        ventilationHour = volume * airChanges * temperatureDifference * ventilationFactor;
        return ventilationHour;
    }
    
}//end of ventilation
